/**
 *  @file  vsOS.h version 1.0 2007-11-20 
 *  @brief Wrappers for the OS functions, so they're cross platforms.
 *  Copyright (c) 2007 by @author <abitfree@gmail.com>
 */

#ifndef __VS_OS_H__
#define __VS_OS_H__

namespace vs
{

//@{
/**
 * Some functions only need to define again.
 */
#ifdef WIN32
#define snprintf _snprintf
#else	// WIN32
#define GetCurrentProcessId getpid
#define GetCurrentThreadId pthread_self
#endif	// WIN32
//@}

/**
 * Sleep/pause for the given number of seconds.
 */
INLINE
void vsSleep( unsigned int seconds )
{
#ifdef WIN32
	Sleep(seconds*1000);
#else
	sleep(seconds);
#endif
}

/**
 * Sleep/pause for the given number of milliseconds.
 */
INLINE
void vsMillisleep( unsigned int msec )
{
#ifdef WIN32
	Sleep(msec);
#else
	usleep(msec*1000);
#endif
}

/**
 * Return current directory string.
 */
INLINE
void GetCurrentDir( char *dir, int maxLen )
{
#ifdef WIN32
	if (!GetCurrentDirectoryA(maxLen, dir))
	dir[0] = 0;
#else
	if (!getcwd(dir, maxLen))
	dir[0] = 0;
#endif
}

} // namespace vs

#endif // __VS_OS_H__
